#ifndef GRAPHICS_UTILS_H
#define GRAPHICS_UTILS_H

#include <graphics/vertexarray.h>
#include <graphics/vertexbuffer.h>
#include <graphics/indexbuffer.h>
#include <graphics/mesh.h>
#include <render/texture2d.h>
#include <render/texture3d.h>

#define SAFE_DELETE(p) if(p) { delete p; p=0; }

namespace yam3d
{
namespace graphics
{

    void printGLString(const char *name, int s);

    void checkGlError(const char* op, ...);

    Mesh* genSphere( int numSlices, float radius );
    Mesh* genPlane( int numXVerts, int numYVerts, float sizeX = 1.0f, float sizeY = 1.0f, float texCoordSizeX = 1.0f, float texCoordSizeY = 1.0f );
    Mesh* genBox( float sizeX = 1.0f, float sizeY = 1.0f, float texCoordSizeX = 1.0f, float texCoordSizeY = 1.0f );

    render::Texture2D* createChessTexture(int sizeX, int sizeY, int checkSize, bool genMipMaps=true);
    render::Texture3D* createBoxTexture(int sizeX, int sizeY, int sizeZ, bool genMipMaps=true);

    core::vector<core::byte> readFileByteData(const core::string& fileName);
    core::vector<unsigned short> readFileUShortData(const core::string& fileName);

    class Utils {
    public:
        Utils();
    };

}
}

#endif // GRAPHICS_UTILS_H
